//跳跃游戏
//https://leetcode.cn/problems/jump-game/description/?envType=study-plan-v2&envId=top-interview-150
class Solution {
public:
    bool canJump(vector<int>& nums) 
    {
        int n = nums.size();
        int dest = 0;
        for(int i = 0; i < n; i++)
        {
            //不可以走到
            if(i > dest) return false;
            dest = max(dest, i + nums[i]);
            //提前结束 
            if(dest >= n - 1) return true;
        }    
        return true;
    }
};